1469A Regular Bracket Sequence codeofrces solution in cpp
by ujjal roy
#include<bits/stdc++.h>
using namespace std;
main()
{
int t,i;
cin>>t;
while(t--)
{
string s;
cin>>s;
int l=s.size();
if((l%2==0)&&(s[0]!=')')&&(s[l-1]!='(')) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
return 0;
}
0 Comments